package com.pilipala.config;

import com.pilipala.properties.AliOssProperty;
import com.pilipala.utils.AliOssUtil;
import com.pilipala.utils.EmailUtil;
import org.apache.commons.validator.routines.EmailValidator;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class CommonUtilConfig {

    @Bean
    public EmailUtil emailUtil(){
        return new EmailUtil();
    }

    @Bean
    public EmailValidator emailValidator(){
        return EmailValidator.getInstance();
    }

    @Bean
    public AliOssUtil aliOssUtil(AliOssProperty aliOssProperty){
        return new AliOssUtil(aliOssProperty.getEndpoint(),
                aliOssProperty.getAccessKeyId(),
                aliOssProperty.getAccessKeySecret(),
                aliOssProperty.getBucketName());
    }
}
